﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using CUWo.Common.Entities.WoInterface.HttpArgument;

/**
 * 创建时间：2014/11/4 10:53:44
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace CUWo.Common.WoInterfaceCommunication
{
    public class PasswordUpdate : CommunicationBase
    {
        public PasswordUpdate()
            : base()
        {
        }

        /// <summary>
        /// 重置密码
        /// </summary>
        /// <param name="mobileNumber"></param>
        /// <returns></returns>
        public string GetUrl(string mobileNumber, string originalPassword, string newPassword)
        {
            ArgsBase argsBase = base.InitHttpCommBass<ArgsPasswordUpdate>();
            ArgsPasswordUpdate args = argsBase as ArgsPasswordUpdate;
            args.MobileNumber = mobileNumber;
            args.OriginalPassword = originalPassword;
            args.NewPassword = newPassword;
            //
            StringBuilder requestUrl = new StringBuilder();
            requestUrl.Append(base.ServiceAddress);//请求地址
            requestUrl.Append(base.Method_MobileSign);//功能ID
            requestUrl.Append("?");
            requestUrl.Append(string.Concat(base.ServiceAddressRequestQueryChannelKey, "=", base.CHANNEL_ID));
            requestUrl.Append("&");
            requestUrl.Append(string.Concat(base.ServiceAddressRequestQueryKey, "="));
            //
            //AES加密
            string cipherString = JSONHelper.Serialize<ArgsPasswordUpdate>(args);
            string result = AESHelper.Byte2Hex(new AESHelper(AESHelper.KeySize.Bits128, AESHelper.Hex2Byte(base.CHANNEL_PASSWORD)).Cipher(Encoding.UTF8.GetBytes(cipherString)));
            requestUrl.Append(result);
            //
            LogHelper.LogInfo(requestUrl.ToString(), this.GetType(), MethodBase.GetCurrentMethod());
            //
            return requestUrl.ToString();
        }
    }

}
